From 044aeaa61620ce89fee084cfb03f7afa783d8b5d Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Wed, 18 Oct 2006 17:45:19 +0100 Subject: [PATCH] [XEN] Clamp dom0 memory and CPUs to fit in available resources. Signed-off-by: Keir Fraser --- xen/arch/x86/domain_build.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c index f858adab51..b8765be263 100644 --- a/xen/arch/x86/domain_build.c +++ b/xen/arch/x86/domain_build.c @@ -286,7 +286,8 @@ int construct_dom0(struct domain *d, nr_pages = avail_domheap_pages() + initial_images_nrpages() + dom0_nrpages; else - nr_pages = dom0_nrpages; + nr_pages = min(avail_domheap_pages() + initial_images_nrpages(), + (unsigned long)dom0_nrpages); if ( (rc = parseelfimage(&dsi)) != 0 ) return rc; @@ -668,6 +669,8 @@ int construct_dom0(struct domain *d, if ( opt_dom0_max_vcpus == 0 ) opt_dom0_max_vcpus = num_online_cpus(); + if ( opt_dom0_max_vcpus > num_online_cpus() ) + opt_dom0_max_vcpus = num_online_cpus(); if ( opt_dom0_max_vcpus > MAX_VIRT_CPUS ) opt_dom0_max_vcpus = MAX_VIRT_CPUS; printk("Dom0 has maximum %u VCPUs\n", opt_dom0_max_vcpus); -- 2.30.2